<template>
	<view class="content">
		<nav-bars bgColor="transparent" title="产品包列表" fontColor="#000"></nav-bars>
		<view class="wrapper">
			<view class="goodsBox" v-if="goodsList.length>0">
				<view class="goodsItem flex" v-for="(item,index) in goodsList" :key="index" @click="goSkip('/pagesFour/home/pages_product/product/packDetails?id='+item.id)">
					<view class="goods-cover">
						<image :src="item.lead_img">
						</image>
					</view>
					<view class="goods-dateils">
						<view class="columnTop flex">
							<view class="title text-ellipsis">{{item.name}}</view>
							<view class="shareIcon">
								<image  :src="`${baseImg}/static/activity/share-icon.png`"></image>
							</view>
						</view>
						<view class="tag">{{item.area}}
							<text>㎡</text>
						</view>
						<view class="bottomBox flex">
							<view class="pricr flex">
								<text>套餐价：</text>
								<text>￥{{item.price}}</text>
							</view>
							<view class="sidebarRight">
								{{item. product_num || 0}}件商品
							</view>
						</view>
					</view>
				</view>
				<u-loadmore :status="statusLoading" :icon-type="iconType" :load-text="loadText" />
			</view>
			<view class="notList" v-else>
				<image :src="`${baseImg}/static/constr/notList.png`" mode=""></image>
				空空如也
			</view>
		</view>
	</view>
</template>

<script>
	import service_now from '@/service/now.js'
	export default {
		data() {
			return {
				statusLoading: 'loadmore',
				iconType: 'flower',
				loadText: {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '到底了~'
				},
				baseImg: this.$static,
				page: 1,
				pagesize: 10,
				goodsList: [],
			}
		},
		onLoad() {
			this.getProduct();
		},
		methods: {
			getProduct() {
				let params = {
					page: this.page,
					pagesize: this.pagesize
				}
				this.statusLoading = 'loading'
				service_now.productPack(params).then(res => {
					if (res.code == 1) {
						let data = res.data.products;
                        let pageNum=this.pagesize*this.page;
						if (pageNum>res.data.total) {
							this.statusLoading = 'nomore'
						} else {
							this.statusLoading = 'loading'
						}
						this.goodsList = this.goodsList.concat(data)
					}
				})
			},
			goSkip(url){
				uni.navigateTo({
					url: url
				});
			},
		},
		onReachBottom() {
			this.page++;
			if (this.statusLoading == 'loading') {
				this.getProduct();
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		width: 100%;
		height: 100%;

		.wrapper {
			width: 100%;

			.goodsBox {
				width: 96%;
				margin: 60rpx auto;
				position: relative;

				.goodsItem {
					width: 100%;
					height: auto;
					margin-bottom: 60rpx;

					.goods-cover {
						width:28%;
						image {
							width: 190rpx;
							height:190rpx;
							border-radius: 10rpx;
						}
					}

					.goods-dateils {
						width:72%;
						margin-left: 20rpx;
                       .columnTop{
						   width: 100%;
						   justify-content: space-between;
						   position: relative;
						  .title {
						  	width:450rpx;
						  	height: 60rpx;
						  }
						   .shareIcon{
							   width: 80rpx;
							   height:80rpx;
							   image{
								   width: 100%;
								   height: 100%;
								   margin-top: -8px;
							   }
						   }
					   }
						

						.tag {
							width: 200rpx;
							margin: 24rpx 0 0 0;
							height: auto;
							padding-bottom: 10rpx;
						}
                     .bottomBox{
						 align-items: center;
						 justify-content: space-between;
						 .pricr {
						 	width: 350rpx;
						 	height: auto;
						 }
						 .sidebarRight {
							 color: #DDA955;
						 	padding-right: 20rpx;
						 }
					 }
						
					}
				}
			}
		}

		// 没有数据
		.notList {
			position: absolute;
			top: 0;
			left: 0;
			right: 0;
			bottom: 0;
			margin: auto;
			height: 400rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			width: 426rpx;

			image {
				width: 426rpx;
				height: 356rpx;
				margin-bottom: 40rpx;
			}

			font:500 40rpx/56rpx PingFang SC;
			color: #333;
		}
		.text-ellipsis{
			overflow: hidden;
			text-overflow:ellipsis;
			white-space: nowrap;
		}
	}
</style>
